﻿<?php
if($_POST['submit']){
	require_once("../includes/configure.php");
	require_once("../includes/database.php");
	$db = Database::Connect();

	$post_name = $_POST['login_name'];
    $post_pwd = $_POST['login_pwd'];

    $sql = "SELECT * FROM ask_user WHERE username='".$db->Encode($post_name)."' and groupid=1";
    $row = $db->GetSingleRow($sql);

    $error_info = null;

    if(!$row)
    {
    	$error_info ="不存在管理员:".$post_name;
    }else{
    	if(md5($post_pwd)===$row->password){
    		//登陆成功
    		 session_start();
	    	 $_SESSION['admin'] = null;
	    	 $_SESSION['admin'] = $post_name;
	    	 header("location:./");
    	}else{
    		$error_info ="密码错误";
    	}
    }

    $db->Close();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>请登陆</title>
<style media="all" type="text/css">
@import "css/all.css";
</style>
<style type="text/css">
#main {
	padding: 50px;
}

#middle {
	padding: 30px;
}

#submit,#reset {
	padding: 3px;
	padding-left: 15px;
	padding-right: 15px;
}
</style>
</head>
<body>
<div id="main">
<div id="header"><a href="index.html" class="logo"><img
	src="img/logo.gif" alt="" /></a></div>
<div id="middle">

<form action="" method="post" style="text-align: right; width: 400px;">
<p class="error"><?php echo $error_info;?></p>
<p>登录名：<input type="text"  style= "width:100px " name="login_name" /></p>
<p>密  码：<input type="password"  style= "width:100px " name="login_pwd" /></p>
<p><input type="reset" size="30" id="reset" value="重 置" /><input
	type="submit" size="30" name="submit" id="submit" value="登 陆" /></p>
</form>

</div>
<div id="footer"></div>
</div>


</body>
</html>
